--TEST--
resource MySQLndUhConnection::listMethod(resource $connection, string $query, string $achtung_wild, string $par1)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function listMethod($res, $query, $pattern, $par1) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::listMethod($res, $query, $pattern, $par1));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function listMethod($res, $query, $pattern, $par1) {
			/* NOTE: it is not possible to detect the wrong resource type ! */
			return $res;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function listMethod($res, $query, $pattern, $par1) {}
	}

	class proxy4 extends MySQLndUhConnection {
		public function listMethod($res, $query, $pattern, $par1) {
			return -1;
		}
	}

	function test_list_processes($conn, $offset) {
		printf("mysql_list_processes()\n");
		$res = mysql_list_processes($conn);
		if (!$res) {
			printf("[%03d] [%d] '%s'\n", $offset, mysql_errno($conn), mysql_error($conn));
			return false;
		}

		var_dump(mysql_num_rows($res));
		while ($row = mysql_fetch_assoc($res))
			;
		mysql_free_result($res);
	}

	$conn = mysqlnd_uh_test\connect::mysql();
	if (!mysql_query("DROP TABLE IF EXISTS test_fields", $conn)
		|| !mysql_query("CREATE TABLE test_fields(id INT, email CHAR(40))", $conn)
		|| !mysql_query("INSERT INTO test_fields(id, email) VALUES (1, 'spam@me.com')", $conn))
		printf("[001] [%d] '%s'\n", mysql_errno($conn), mysql_error($conn));
	test_list_processes($conn, 2);
	mysqlnd_uh_test\query_test::mysql($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	test_list_processes($conn, 3);
	mysqlnd_uh_test\query_test::mysql($conn);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	test_list_processes($conn, 4);
	mysqlnd_uh_test\query_test::mysql($conn);

	mysqlnd_uh_set_connection_proxy(new proxy3());
	test_list_processes($conn, 5);
	mysqlnd_uh_test\query_test::mysql($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	test_list_processes($conn, 6);
	mysqlnd_uh_test\query_test::mysql($conn);

	print "done!";
?>
--EXPECTF--
mysql_list_processes()
int(%d)
mysql_list_processes()
proxy::listMethod(array (
  0 => NULL,
  1 => 'SHOW PROCESSLIST',
  2 => '',
  3 => '',
))
resource(%d) of type (MySQLnd Resultset (internal only - you must not modify it!))
int(%d)
mysql_list_processes()

Warning: mysql_list_processes(): Unable to save MySQL query result in %s on line %d
[004] [0] ''
mysql_list_processes()

Warning: mysql_list_processes(): Unable to save MySQL query result in %s on line %d
[005] [0] ''
mysql_list_processes()

Warning: mysql_list_processes(): Unable to save MySQL query result in %s on line %d
[006] [0] ''
done!